<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	 <meta charset="utf-8">
	 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	 <title th:replace="common/base::pagetitle"></title>
	 <link th:replace="common/base::static"/>
</head>
<body style="background-color: #f2f2f2;">

<div id="kPage" class="layui-fluid" style="padding: 0">
	 <div class="layui-row wlb-fluid-padding15">
		  <div class="layui-col-md12">
				<div class="layui-card">
					 <div class="layui-card-header">设置我的资料</div>
					 <div class="layui-card-body">
						  <div class="layui-form" lay-filter="">
								<div class="layui-form-item">
									 <label class="layui-form-label">当前密码</label>
									 <div class="layui-input-inline">
										  <input type="password" name="oldPassword" lay-verify="required" lay-vertype="tips" class="layui-input">
									 </div>
								</div>
								<div class="layui-form-item">
									 <label class="layui-form-label">新密码</label>
									 <div class="layui-input-inline">
										  <input type="password" name="password" lay-verify="pass" lay-vertype="tips" autocomplete="off" id="LAY_password" class="layui-input">
									 </div>
									 <div class="layui-form-mid layui-word-aux">8到16个字符</div>
								</div>
								<div class="layui-form-item">
									 <label class="layui-form-label">确认新密码</label>
									 <div class="layui-input-inline">
										  <input type="password" name="repassword" lay-verify="repass" lay-vertype="tips" autocomplete="off" class="layui-input">
									 </div>
								</div>
								
								<div class="layui-form-item">
									 <div class="layui-input-block">
										  <button class="layui-btn" lay-submit="" lay-filter="kFormSubmit">确认修改</button>
									 </div>
								</div>
						  </div>
					 </div>
				</div>
		  </div>
	 </div>
</div>

<script th:replace="common/base::context"></script>
<script th:replace="common/base::mainjs"></script>

<script type="text/javascript" th:inline="javascript">
    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form;

        form.verify({
            pass: function (value, item) {
                // var reg = new RegExp(/^[a-z0-9]{6,16}$/);
                var reg = new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/);
                if (!reg.test(value)) {
                    return '至少8-16个字符，至少1个大写字母，1个小写字母和1个数字';
                }

                // if(value.length < 6 || value.length > 16){
                //     return '6~16位字符';
                // }
            },
            repass: function (value, item) {
                var password = $('input[name="password"]').val();
                if (password !== value) {
                    return '与第一次输入的密码不一致';
                }
            }
        });

        //监听提交
        form.on('submit(kFormSubmit)', function (data) {
            var field = data.field; //获取提交的字段

            $.ajax({
                type: req.type.post,
                url: api.sys.userChangePwd,
                data: field,
                async: false,
                success: function (r) {
                    if (r.code === req.status.ok) {
                        wlbKit.sucessMsg('修改成功');
                    } else {
                        wlbKit.errorMsg(r.msg);
                    }
                }
            });
        });
    });
</script>

</body>
</html>